package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Product;
import cn.wolfcode.crm.mapper.ProductMapper;
<<<<<<< HEAD
import cn.wolfcode.crm.service.IProductService;
import cn.wolfcode.crm.web.controller.ProductController;
=======
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
import cn.wolfcode.crm.domain.SafetyMechanism;
import cn.wolfcode.crm.mapper.SafetyMechanismMapper;
import cn.wolfcode.crm.page.PageResult;
import cn.wolfcode.crm.query.ProductQueryObj;
import cn.wolfcode.crm.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper productMapper;
<<<<<<< HEAD
    @Override
    public List<Product> list(Long smId,Long sStatus) {
        List<Product> products = productMapper.selectAllByCondition(smId,sStatus);

        return products;

    }

    @Autowired
    private SafetyMechanismMapper safetymechanismMapper;
=======
    @Autowired
    private SafetyMechanismMapper safetymechanismMapper;
    @Override
    public List<Product> list(Long smId,Long sStatus) {
        List<Product> products = productMapper.selectAllByCondition(smId,sStatus);
        return products;
    }
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
    @Override
    public List<Product> selectByPolicyId(Long policyId) {
        List<Product> list = productMapper.selectByPolicyId(policyId);
        return list;
    }
<<<<<<< HEAD

    @Override
    public List<Product> listAll() {
        List<Product> products = productMapper.selectAll();

=======
    @Override
    public List<Product> listAll() {
        List<Product> products = productMapper.selectAll();
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
        return products;
    }
    @Override
    public PageResult query(ProductQueryObj qo) {
        int total = productMapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List list = productMapper.queryForList(qo);
        return new PageResult(total, list);
    }
    //查询所有的保险机构
    @Override
    public List selectALL() {
        return productMapper.selectAll();
    }

    @Override
    public void insert(Product product) {
        productMapper.insert(product);
    }

    @Override
    public int update(Product product) {
        return productMapper.updateByPrimaryKey(product);
    }

    @Override
    public List<SafetyMechanism> selectSomeInfo() {
        List<SafetyMechanism> safetyMechanisms = safetymechanismMapper.selectAllIdAndName();
        return safetyMechanisms;
    }


}
